﻿Imports PadovadoAPI
Imports System.Data

Partial Class AdminAggiungiUtente
    Inherits System.Web.UI.Page
    Protected Sub BtnUser_Click(sender As Object, e As System.EventArgs) Handles BtnUser.Click
        Dim PK_anagrafica As Integer = CntlAnagrafica.InsertAnagrafica()
        Dim sql As String = "INSERT INTO Utente (username, password, intRuolo, FK_Anagrafica, deleted) VALUES('" & _
            TBUsername.Text & "', '" & Utente.md5(TBPassword.Text).ToString & "'," & DDLRuolo.SelectedIndex & ", " & PK_anagrafica & ", 0)"
        Dim dbo As New DBObject
        dbo.ExecuteNonQuery(sql, Nothing, CommandType.Text)

    End Sub

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If String.IsNullOrEmpty(Session("UserInSession")) Then
            Response.Redirect("Admin.aspx")
        End If
    End Sub

    Protected Sub LinkButton1_Click(sender As Object, e As System.EventArgs) Handles LinkButton1.Click
        Session("UserInSession") = Nothing
        Response.Redirect("Default.aspx")
    End Sub
End Class
